package com.bjgov.scoresys.entity;
// default package

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.OrderBy;

/**
 * ScoreItem entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "score_item", catalog = "scoresys")
public class ScoreItem implements java.io.Serializable {

	// Fields

	private Integer id;
	private ScoreTree scoreTree;
	private String itemName;
	private String itemDesc;
	private String itemUrlDesc;
	private Short status;
	//private Short qualityType;
	private Set<ProjectItems> projectItemses = new HashSet<ProjectItems>(0);

	// Constructors

	/** default constructor */
	public ScoreItem() {
	}

	/** minimal constructor */
	public ScoreItem(ScoreTree scoreTree, String itemName) {
		this.scoreTree = scoreTree;
		this.itemName = itemName;
	}

	/** full constructor */
	public ScoreItem(ScoreTree scoreTree, String itemName, String itemDesc,String itemUrlDesc,
			Short status,Short qualityType, Set<ProjectItems> projectItemses) {
		this.scoreTree = scoreTree;
		this.itemName = itemName;
		this.itemDesc = itemDesc;
		this.itemUrlDesc = itemUrlDesc;
		this.status = status;
		//this.qualityType=qualityType;
		this.projectItemses = projectItemses;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PID", nullable = false)
	public ScoreTree getScoreTree() {
		return this.scoreTree;
	}

	public void setScoreTree(ScoreTree scoreTree) {
		this.scoreTree = scoreTree;
	}

	@Column(name = "ITEM_NAME", nullable = false, length = 400)
	public String getItemName() {
		return this.itemName;
	}

	public void setItemName(String itemName) {
		this.itemName = itemName;
	}

	@Column(name = "ITEM_DESC", length = 400)
	public String getItemDesc() {
		return this.itemDesc;
	}

	public void setItemDesc(String itemDesc) {
		this.itemDesc = itemDesc;
	}
	
	@Column(name = "ITEM_URL_DESC",  length=65535)
	public String getItemUrlDesc() {
		return this.itemUrlDesc;
	}

	public void setItemUrlDesc(String itemUrlDesc) {
		this.itemUrlDesc = itemUrlDesc;
	}	

	@Column(name = "[STATUS]")
	public Short getStatus() {
		return this.status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}
	
//	@Column(name = "[Quality_Type]")
//	public Short getQualityType() {
//		return qualityType;
//	}
//
//	public void setQualityType(Short qualityType) {
//		this.qualityType = qualityType;
//	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "scoreItem")
	@OrderBy(clause="id asc")
	public Set<ProjectItems> getProjectItemses() {
		return this.projectItemses;
	}

	public void setProjectItemses(Set<ProjectItems> projectItemses) {
		this.projectItemses = projectItemses;
	}

}